package cn.aifeix.basic.controller;

import cn.aifeix.basic.dto.EmailRegisterDto;
import cn.aifeix.basic.dto.PhoneRegisterDto;
import cn.aifeix.basic.service.IRegisterService;
import cn.aifeix.basic.util.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

@RestController
@RequestMapping("/register")
public class RegisterController {

    @Autowired
    private IRegisterService iRegisterService;
    /**
     * 手机注册接口
     */
    @PostMapping("/phone")
    public AjaxResult phoneRegister(@RequestBody @Valid PhoneRegisterDto dto){
        iRegisterService.phoneRegister(dto);
        return AjaxResult.me().success();
    }

    /**
     * 邮箱注册接口
     */
    @PostMapping("/email")
    public AjaxResult emailRegister(@RequestBody @Valid EmailRegisterDto dto){
        iRegisterService.emailRegister(dto);
        return AjaxResult.me().success();
    }
}
